package com.woniu.user.controller;

import com.woniu.common.dto.RechargeOrderDto;
import com.woniu.common.util.ResponseData;
import com.woniu.user.pojo.TUser;
import com.woniu.user.pojo.TUserAddr;
import com.woniu.user.service.TUserAddrService;
import com.woniu.user.service.TUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author 杜梅杰
 * @description
 * @date 2024/5/6 19:42
 */
@RestController
public class UserController {
    @Autowired
    private TUserAddrService addrService;

    @Autowired
    private TUserService userService;
    /**
     * 获取地址信息
     **/
    @PostMapping("/getAddr")
    public TUserAddr getAddr(Long addrId) {
        return addrService.getById(addrId);
    }

    @PostMapping("/queryUser")
    public ResponseData<TUser> queryUser(String phone){
        return userService.getByPhone(phone);
    }

    /**
     * 增加话费
     */
    @PostMapping("/updatePhoneBill")
    public ResponseData<TUser> updatePhoneBill(@RequestBody RechargeOrderDto rechargeOrderDto){
        return userService.updatePhoneBill(rechargeOrderDto);
    }


    /**
     * 扣用户150积分
     */
    @GetMapping("/deletePhoneBill")
    public ResponseData<?> deletePhoneBill(String phone){
        return userService.deletePhoneBill(phone);
    }



}
